//冒泡排序模板代码
public class code1 {
    public static void main(String[] args) {
        int []arr = {5,4,3,2,1};
        //i代表趟数,j用来表示相邻元素的下标
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j+1 < arr.length-i; j++) {
                //可以进行修改，看是从小排到大还是从大排到小
                if (arr[j]>arr[j+1]) {
                    int tmp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tmp;
                }
            }
        }
    }
}
